// JavaScript Document
function backPage(f)
{
	
	window.document.forms[0].target = "_self";
	window.document.forms[0].action	= f;
	window.document.forms[0].submit();
	
}
function MM_goToURL() 
{ //v3.0
	
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");

}

function deleteRecord(strID, strUrlList)
{
	
	if (strID != "")
	{
		var SayYes = confirm("Bạn có chắc muốn xóa không: " + strID+"*")
		if (SayYes == true)
			backPage(strUrlList);
	}
}

function deleteAllRecord(strUrlList)
{
	strID=""
	
	with (document.forms[0])
	{
		len = elements.length;
		
		for(var ii=0; ii<len; ii++)
		{
			
			if (elements[ii].name == "chkDel[]") 
				if (elements[ii].checked)
					strID = strID + elements[ii].value;
		}//end for
	}//end with	
	if (strID != "")
	{
		var SayYes = confirm("Bạn có chắc muốn xóa không? ")
		if (SayYes == true)
			backPage(strUrlList)
	}
}
function deleteImages(nID, strUrl)
{
	if (nID != "")
	{
		var SayYes = confirm("Bạn có chắc muốn xóa không")
		if (SayYes == true)
			backPage(strUrl);
	}
}
function AddTo(objMau, objDe)		
{
	var i = objMau.selectedIndex;
	
	var j,k;
	var bIns = false;
	if (i == -1) return 0;
	for(k = objMau.options.length-1; k >= 0 ; k--)
	{
		
		bIns = false;
		if (objMau.options[k].selected == true)
		{
			var f1 = objMau.options[k].text;
			var f2 = objMau.options[k].value;
			if (checkExist( f2, objDe) == false)
			{
				var total = objDe.options.length;
				var oOption = document.createElement("OPTION");
				objDe.options.add(oOption);
				oOption.text = f1;
				oOption.value = f2
				oOption.selected = true;
				window.document.forms[0].txt.value += f2 + ",";
			}else
		
			{
				alert("Đã tồn tại rồi");
			}
		}
	}
	updatehidden(objDe);
}
function ReMove( objDe)
{
	var i = objDe.selectedIndex;
	
	var j,k;
	var bIns = false;
	if (i == -1) return 0;
	for(k = objDe.options.length-1; k >= 0 ; k--)
	{
		
		bIns = false;
		if (objDe.options[k].selected == true)
		{
			var f1 = objDe.options[k].text;
			var f2 = objDe.options[k].value;
			var oOption = document.createElement("OPTION");
			objDe.remove(k)	;
		}
	}
	updatehidden(objDe);
}
function checkExist( value ,objDe )
{
	for(k = objDe.options.length-1; k >= 0 ; k--)
	{			
		var f2 = objDe.options[k].value;		
		if( value == f2 )
			return true;
	}
	return false;
}
function updatehidden(objDe)
{
	document.forms[0].txt.value = "";
	for(k = objDe.options.length-1; k >= 0 ; k--)
	{
		
			var f2 = objDe.options[k].value;
			
			document.forms[0].txt.value += f2 + ","

	}		
}
/**/
function showTypeN( name )
{
	var obj = document.getElementById( name );
	var o = document.getElementsByTagName( "table" );

	if( obj.style.display != "" )
		obj.style.display = "";
	else
	obj.style.display = "none";
}
/**/
function AddToUser(objMau, objDe)		
{
	var i = objMau.selectedIndex;
	
	var j,k;
	var bIns = false;
	if (i == -1) return 0;
	for(k = objMau.options.length-1; k >= 0 ; k--)
	{
		
		bIns = false;
		if (objMau.options[k].selected == true)
		{
			var f1 = objMau.options[k].text;
			var f2 = objMau.options[k].value;
			if (checkExist( f2, objDe) == false)
			{
				var total = objDe.options.length;
				var oOption = document.createElement("OPTION");
				objDe.options.add(oOption);
				oOption.text = f1;
				oOption.value = f2
				oOption.selected = true;
				window.document.forms[0].txt.value += f2 + ",";
			}else
		
			{
				alert("Đã tồn tại rồi");
			}
		}
	}
	updatehiddenUser(objDe);
}
function ReMoveUser( objDe)
{
	var i = objDe.selectedIndex;
	
	var j,k;
	var bIns = false;
	if (i == -1) return 0;
	for(k = objDe.options.length-1; k >= 0 ; k--)
	{
		
		bIns = false;
		if (objDe.options[k].selected == true)
		{
			var f1 = objDe.options[k].text;
			var f2 = objDe.options[k].value;
			var oOption = document.createElement("OPTION");
			objDe.remove(k)	;
		}
	}
	updatehiddenUser(objDe);
}
function checkExistUser( value ,objDe )
{
	for(k = objDe.options.length-1; k >= 0 ; k--)
	{			
		var f2 = objDe.options[k].value;		
		if( value == f2 )
			return true;
	}
	return false;
}
function updatehiddenUser(objDe)
{
	document.forms[0].txt.value = "";
	for(k = objDe.options.length-1; k >= 0 ; k--)
	{
		
			var f2 = objDe.options[k].value;
			
			document.forms[0].txt.value += f2 + ","

	}		
}
